using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NCS.Module.CMS.Library.Definitions;
using NCS.Library.Utilities;
using NCS.Module.CMS.Library.Comments;
using NCS.Library.Components.Security;

namespace NCS.Module.CMS.Admin.WorkFlow
{
    public partial class CommentUpdate : AuthenticatedControl
    {
        protected UserControls.Editor Editor1;
        protected void Page_Load(object sender, EventArgs e)
        {
            Editor1.UploadDir = Constants.UploadPath + "/Comment";
            if (!Page.IsPostBack)
            {
                int commentid = ConvertUtility.ToInt32(Request.QueryString["commentid"]);
                CommentInfo cominfo = CommentDB.GetInfo(commentid);
                //				txtComment.Text=cominfo.Comment_Content;
                Editor1.HTMLValue = cominfo.Comment_Content;
            }
        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            int commentid = ConvertUtility.ToInt32(Request.QueryString["commentid"]);
            CommentInfo cominfo = CommentDB.GetInfo(commentid);
            //			cominfo.Comment_Content=txtComment.Text;
            cominfo.Comment_Content = Editor1.HTMLValue;
            try
            {
                CommentDB.Update(cominfo);
                lbmes.Text = MiscUtility.MSG_UPDATE_SUCCESS;
                this.AddLog("CMS Comment", " try update comment " + cominfo.Content_ID + " success");
            }
            catch(Exception ex)
            {
                lbmes.Text = MiscUtility.MSG_UPDATE_ERROR;
                this.AddLog("CMS Comment", " try update comment error: " + ex.Message);
            }
        }
    }
}